<template lang="pug">
  kalix-dialog.user-add(bizKey="messagereply" ref="kalixBizDialog"
    v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL" v-bind:submitBefore="submitBefore")
    div.el-form(slot="dialogFormSlot")
      <!--input(v-model="formModel.parentId" type="hidden")-->
      <!--input(v-model="formModel.messageId" type="hidden")-->
      <!--input(v-model="formModel.isLeaf" type="hidden")-->
      <!--input(v-model="formModel.userName=userName" type="hidden")-->
      el-form-item(label="所属帖子内容" prop=" " label-width="120px" v-bind:rules="rules.parentContent")
        el-input(v-text="formModel.parentContent")
      el-form-item(label="回复人姓名" prop="userName" label-width="120px" v-bind:rules="rules.userName")
        el-input(v-model="formModel.userName" style="width:80%")
      el-form-item(label="回复内容" prop="replyMessage" label-width="120px" v-bind:rules="rules.replyMessage")
        textarea.retextarea(v-model="formModel.replyMessage")
      el-form-item(label="图片" prop="photo" v-bind:label-width="labelWidth")
        kalix-clansman-upload(:action="action" v-on:filePath="getFilePath" fileType="img" tipText="只能上传jpg/png文件" )
</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {MessageReplyURL} from '../../config.toml'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  export default {
    name: 'messagereplyAdd',
    components: {KalixClansmanUpload},
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        rules: {
          // parentName: [{required: true, message: '上级功能不能为空', trigger: 'blur'}],
          userName: [{required: true, message: '请输入回复人姓名', trigger: 'blur'}],
          replyMessage: [{required: true, message: '请输入回复内容', trigger: 'blur'}]
        },
        targetURL: MessageReplyURL,
        action: baseURL + '/camel/rest/upload',
        filePathArr: [],
        fileNameArr: [],
        labelWidth: '110px'
      }
    },
    computed: {
    },
    created() {
    },
    mounted() {
    },
    methods: {
      init(dialogOption) {
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)
        this.filePathArr.push(filePath)
        this.fileNameArr.push(fileName)
      },
      submitBefore(baseDialog, callBack) {
        console.log('===FilePath=================', this.filePathArr)
        let filePath = ''
        if (this.filePathArr.length) {
          this.filePathArr.forEach(e => {
            filePath += e + ','
          })
          filePath = filePath.substr(0, filePath.length - 1)
        }
        let fileName = ''
        if (this.fileNameArr.length) {
          this.fileNameArr.forEach(e => {
            fileName += e + ','
          })
          fileName = fileName.substr(0, fileName.length - 1)
        }
        baseDialog.formModel.photo = filePath
        baseDialog.formModel.imgName = fileName
        callBack()
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .retextarea
    width 80%
    height 300px
    resize:none
</style>
